<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ForGetPasswordValidata extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
     public function rules()
     {
         return [
             'phone'                 => ['required', 'regex:/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/u'],
             'password'              => 'required|confirmed|min:6',
             'password_confirmation' => 'required',
             'code'                  => 'required|max:6|min:6',
         ];
     }

     public function messages()
     {
         return [
             'code.max'                       => '验证码不能大于六位',
             'code.min'                       => '验证码不能小于六位',
             'code.required'                  => '验证码不能为空',
             'phone.required'                 => '手机号码不能为空',
             'phone.regex'                    => '手机号格式不正确',
             'password.required'              => '密码不能为空',
             'password.min'                   => '密码不能少于6位',
             'password.confirmed'             => '两次密码内容不相同',
             'password_confirmation.required' => '确认密码不能为空',
             'password_confirmation.min'      => '密码不能少于6位',
         ];
     }
}
